package com.scau.data.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.scau.data.entity.ShopLineDO;
import com.scau.database.entity.salesperson.SalesInfoItemVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ShopLineMapper extends BaseMapper<ShopLineDO> {


    /**
     * 然后通过流水号获取商品列表，同时需要根据商品barCode从commodity_info和on_sell获取商品名、店铺三包、厂家三包
     * @param shopId 流水号
     * @return
     */
    @Select("SELECT shop_line.shop_id, shop_line.index, " +
            "shop_line.bar_code, shop_line.order_number, " +
            "shop_line.shelf_id, shop_line.count, " +
            "shop_line.deal_price, commodity_info.name as commodity, " +
            "commodity_info.repair_days as factory_repair_days, " +
            "commodity_info.return_days as factory_return_days, " +
            "commodity_info.exchange_days as factory_exchange_days, " +
            "on_sell.repair_days as store_repair_days, " +
            "on_sell.return_days as store_return_days, " +
            "on_sell.exchange_days as store_exchange_days " +
            "FROM shop_line " +
            "INNER JOIN commodity_info ON shop_line.bar_code = commodity_info.bar_code " +
            "INNER JOIN on_sell ON shop_line.bar_code = on_sell.bar_code " +
            "WHERE shop_line.shop_id = #{shopId}")
    List<SalesInfoItemVO> getSalesInfoItemsByShopId (Long shopId);


}
